k = imfinfo('sign3.tif');
A = imread('sign3.tif');
if(strcmp(k.ColorType,'truecolor')==1)
    B = rgb2gray(A);
elseif(strcmp(k.ColorType,'grayscale')==1)
        B = A;
end

% figure,imshow(B);

new_dim = max(size(B));

C = zeros(new_dim,new_dim);
C(1:size(B,1),1:size(B,2))=B;

%figure,imshow(mat2gray(C));

alpha1 = 0.90;

T = dFRT(new_dim,alpha1);

F1 = T*C*T;

% if(alpha1 > 0.5)
%     figure,imshow(fftshift(im2uint8(mat2gray(log(1+abs(F1))))));
% else
%     figure,imshow(im2uint8(mat2gray(log(1+abs(F1)))));
% end

ctr1 = 1;
X = imread('cameraman.tif');
for alpha2 = 0.7 : 0.1 : 0.9
    

% figure,imshow(X);

    T = dFRT(256,alpha2);

    F2 = T*double(X)*T;



    [mag_array loc] = sort(abs(F2(:)),'descend');

    ctr2 = 1;

    for percent = 0 : 0.05 : .35

        start_pt = 1+floor(percent * length(loc));



        r = real(F2(loc(start_pt:start_pt+length(F1(:))-1)));
        im = imag(F2(loc(start_pt:start_pt+length(F1(:))-1)));


        add_r = real(F1(:));
        add_im = imag(F1(:));

        max_real = max(add_r);
        max_imag = max(add_im);


        factor = 70;

        r1 = r + factor*(add_r/max_real);
        im1 = im + factor*(add_im/max_imag);



        F2(loc(start_pt:start_pt+numel(F1)-1)) = r1 + j*im1;

        T = dFRT(256,-alpha2);

        F3 = T*F2*T;

        F3 = im2uint8(mat2gray(abs(F3)));



        r_arr(ctr1,ctr2) = imagermse(im2uint8(mat2gray(abs(F3))),X);

        ctr2 = ctr2 + 1;

    end
    ctr1 = ctr1 + 1;
end



plot(r_arr(1,:),'kx-');hold on
plot(r_arr(2,:),'bo-');hold on
plot(r_arr(3,:),'r<-');title('Plot of rmse against embedding location');legend('\alpha = 0.7','\alpha=0.8','\alpha=0.9')
%set(gca,'xtick',0:0.05:0.35);
xlabel('Embedding position as % of array length');
ylabel('RMSE')